__________________________________________________________________________________________________
class Solution {
    public int dayOfYear(String date) {
        String[] s = date.split("-");
        int y = Integer.valueOf(s[0]);
        int m = Integer.valueOf(s[1]);
        int d = Integer.valueOf(s[2]);
        return enc(y, m, d) - enc(y, 1, 1) + 1;
    }
    
    public int[] DOM = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    public int[] CUMDOM = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
    
    public int[] DOM_LEAP = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    public int[] CUMDOM_LEAP = {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335};
    
    public int enc(int y, int m, int d)
    {
        int ret = 0;
        ret += (y-1) * 365;
        ret += (y-1) / 4;
        ret -= (y-1) / 100;
        ret += (y-1) / 400;
        ret += CUMDOM[m-1];
        if(m >= 3 && y % 4 == 0 && (y % 400 == 0 || y % 100 != 0)){
            ret++;
        }
        ret += d;
        return ret-1;
    }
}	
__________________________________________________________________________________________________

__________________________________________________________________________________________________
